#ifndef LIB_GEOUTILS_COLORMAPPER_H
#define LIB_GEOUTILS_COLORMAPPER_H
#include "libGeoutils/tool/color_rgb.h"

namespace geo {
namespace tool {
class GEOUTILS_EXPORT ColorMapper : public prop::Properties
{
public:
	using sptr = std::shared_ptr<ColorMapper>;
	using csptr = std::shared_ptr<const ColorMapper>;
	using ColorSegment = std::pair<ColorRGBA::sptr, ColorRGBA::sptr>;

	ColorMapper(const std::string& name, int number = 0);
	virtual ~ColorMapper();

	void setName(const std::string& name);
	std::string getName() const;

	void setNumber(int number);
	int getNumber() const;

	void setStartingColor(ColorRGBA::sptr color);
	void setEndingColor(ColorRGBA::sptr color);

	void appendColorStop(double gray_value, ColorRGBA::sptr color);
	void appendColorStop(double gray_value, ColorRGBA::sptr end_color, ColorRGBA::sptr start_color);
	ColorRGBA::sptr mapGray2Color(double gray_value) const;
	void clearStops();

	bool to_string(std::string& out_str) const override;
	bool to_json(std::string& out_str) const override;
	bool from_json(const std::string& in_str) override;

protected:
	std::map<double, ColorSegment> mColors;
	ColorRGBA::sptr mStartingColor;
	ColorRGBA::sptr mEndingColor;

private:

};

} // namespace tool
} // namespace geo

#endif // !LIB_GEOUTILS_COLORMAPPER_H
